package com.qinhailin.portal.dbm.ctrl;

import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.Logger;

import com.alibaba.fastjson.JSONArray;
import com.jfinal.aop.Clear;
import com.jfinal.aop.Inject;
import com.qinhailin.common.base.BaseController;
import com.qinhailin.common.routes.ControllerBind;
import com.qinhailin.common.util.AESUtil;
import com.qinhailin.portal.dbm.model.CTCustomer;
import com.qinhailin.portal.dbm.po.QueryText;
import com.qinhailin.portal.dbm.po.SessionKill;
import com.qinhailin.portal.dbm.po.SessionKilling;
import com.qinhailin.portal.dbm.service.CTCustomerServiceImpl;
import com.qinhailin.portal.dbm.service.DPListsessionkillingServiceImpl;

/**
 * 查询要杀死的线程
 * @author ward
 */
@ControllerBind(path="/portal/dbm/sessionkill")
@Clear
public class SessionKillController extends BaseController{
	
	private static final Logger log = Logger.getLogger(SessionKillController.class);
	
	@Inject
	private CTCustomerServiceImpl customerService;
	@Inject
	private DPListsessionkillingServiceImpl sessionkillingService;
	
	
	
	public void index() {
		Integer rCustID = this.getInt();
		CTCustomer c = customerService.findByID(rCustID);
		List<SessionKill> sks = new ArrayList<>();
		List<SessionKilling> listsessionkilling = sessionkillingService.dp_listsessionkilling(rCustID);
		if(listsessionkilling != null) {
			for(SessionKilling d : listsessionkilling) {
				sks.add(new SessionKill().setSessionID(d.getSPID()).setStartTime(d.getXStartTime()));
			}
		}
		this.renderJson(AESUtil.encrypt(JSONArray.toJSONString(sks), c.getXKey()));
	}
		

}
